package xyz.hzxiao.user.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.hzxiao.entity.order.DemoOrderEntity;
import xyz.hzxiao.entity.user.DemoUserEntity;
import xyz.hzxiao.result.JsonResult;
import xyz.hzxiao.user.service.DemoUserService;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author FuXx
 * @since 2023-12-05
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
public class DemoUserController {

    private final DemoUserService currentService;

    @GetMapping("/userLogin")
    public JsonResult<DemoUserEntity> user(String userName, String pass) {
        return currentService.login(userName, pass);
    }


    @GetMapping("/getByOptionNumber")
    public JsonResult<List<DemoUserEntity>> getByOptionNumber(String optionNumber) {
        return currentService.getByOptionNumber(optionNumber);
    }

    @GetMapping("/queryOrdersByUserId/{id}")
    public JsonResult<List<DemoOrderEntity>> queryOrdersByUserId(@PathVariable("id") Integer id) {
        return currentService.queryOrdersByUserId(id);
    }

}
